package leetcode.code0478;

import java.util.Random;

public class Solution {
	double r, x, y;

	public Solution(double radius, double x_center, double y_center) {
		this.r = radius;
		this.x = x_center;
		this.y = y_center;
	}

//	public double[] randPoint() {
//		while (true) {
//			double X = Math.random() * (2 * r) + x - r;
//			double Y = Math.random() * (2 * r) + y - r;
//			double d1 = X - x;
//			double d2 = Y - y;
//			if (r * r >= d1 * d1 + d2 * d2) {
//				return new double[] { X, Y };
//			}
//		}
//	}
	public double[] randPoint() {
		double R = Math.random() * r;
		double d = Math.random() * 720;
		double X = Math.sin(d) * R;
		double Y = Math.cos(d) * R;
		return new double[] { x + X, y + Y };
	}

	public static void main(String[] args) {
		Solution so = new Solution(1, 0, 0);
		double[] ans = so.randPoint();
		System.out.println(ans[0] + " " + ans[1]);
//		System.out.println(Math.random() * 0.01);

//		System.out.println(Math.atan(0));
//		System.out.println(Math.atan(45));
//		System.out.println(Math.atan(90));
//		System.out.println(Math.atan(180));
//		System.out.println(Math.atan(270));
//		System.out.println(Math.atan(360));
		System.out.println(Math.sin(0));
		System.out.println(Math.sin(45));
		System.out.println(Math.sin(90));
		System.out.println(Math.sin(180));
		System.out.println(Math.sin(270));
		System.out.println(Math.sin(360));
//		System.out.println(Math.cos(0));
//		System.out.println(Math.cos(45));
//		System.out.println(Math.cos(90));
//		System.out.println(Math.cos(180));
//		System.out.println(Math.cos(270));
//		System.out.println(Math.cos(360));
	}
}
